package com.example.mybackend.service;

import com.example.mybackend.entity.administrator;
import com.example.mybackend.exception.ServiceException;
import com.example.mybackend.mapper.administratorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class administratorServiceImpl implements administratorService {
    @Autowired
    private administratorMapper administratorMapper;

    @Override
    public administrator login(administrator Administrator) {
         administrator dbAdmin=administratorMapper.select(Administrator);
         if(dbAdmin==null){
             //抛出自定义异常
             throw new ServiceException("用户名或密码错误");
         }
         if(!Administrator.getPassWord().equals(dbAdmin.getPassWord())){
             throw new ServiceException("用户名或密码错误");
         }
        return dbAdmin;
    }
}
